//
//  RFAApplicationDelegate.m
//  RFA Manager
//
//  Created by Torsten Kammer on 30.03.08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "RFAApplicationDelegate.h"
#import "MyDocument.h"

@implementation RFAApplicationDelegate

@synthesize saveAndRunEnabled, canExtract, canDelete, canAddFiles, canMakeNewFolder;

- (IBAction)createNewFolder:(id)sender;
{
	[[[NSDocumentController sharedDocumentController] currentDocument] createNewFolder:sender];
}

- (IBAction)deleteItems:(id)sender;
{
	[[[NSDocumentController sharedDocumentController] currentDocument] deleteItems:sender];
}

- (IBAction)addFiles:(id)sender;
{
	[[[NSDocumentController sharedDocumentController] currentDocument] addFiles:sender];
}

- (IBAction)extractFiles:(id)sender;
{
	[[[NSDocumentController sharedDocumentController] currentDocument] extractFiles:sender];
}

- (IBAction)run:(id)sender;
{
	[[[NSDocumentController sharedDocumentController] currentDocument] run:sender];
}

- (IBAction)saveAndRun:(id)sender;
{
	[[[NSDocumentController sharedDocumentController] currentDocument] saveAndRun:sender];
}

- (IBAction)useBrowserView:(id)sender;
{
	[[[NSDocumentController sharedDocumentController] currentDocument] setViewMode:0];
}
- (IBAction)useListView:(id)sender;
{
	[[[NSDocumentController sharedDocumentController] currentDocument] setViewMode:1];
}

- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
    if ([menuItem action] == @selector(deleteItems:)) return [[[NSDocumentController sharedDocumentController] currentDocument] canDelete];
    else if ([menuItem action] == @selector(createNewFolder:)) return [[[NSDocumentController sharedDocumentController] currentDocument] canMakeNewFolder];
    else if ([menuItem action] == @selector(addFiles:)) return [[[NSDocumentController sharedDocumentController] currentDocument] canAddFiles];
    else if ([menuItem action] == @selector(extractFiles:)) return [[[NSDocumentController sharedDocumentController] currentDocument] canExtract];
    else if ([menuItem action] == @selector(run:)) return [[[NSDocumentController sharedDocumentController] currentDocument] saveAndRunEnabled];
    else if ([menuItem action] == @selector(saveAndRun:)) return [[[NSDocumentController sharedDocumentController] currentDocument] saveAndRunEnabled];
    else if ([menuItem action] == @selector(useBrowserView:)) return [[[NSDocumentController sharedDocumentController] currentDocument] tabToShow] < 2;
    else if ([menuItem action] == @selector(useListView:)) return [[[NSDocumentController sharedDocumentController] currentDocument] tabToShow] < 2;

    return NO;
}

@end
